import Cookies from 'js-cookie'

const TOKEN_NAME = 'login_user'
const REFER_TOKEN_NAME = 'cm_refer_token'

//
export function getToken () {
  return Cookies.get(TOKEN_NAME)
}

export function setToken (token) {
  // const expires = Math.round(exp / (24 * 3600))
  return Cookies.set(TOKEN_NAME, token, { expires: 14 })
}

export function setRefToken (token) {
  return Cookies.set(REFER_TOKEN_NAME, token)
}

export function removeToken () {
  return Cookies.remove(TOKEN_NAME)
}
